# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=java-sigar
_pkgname=sigar
pkgver=1.6.4
pkgrel=1
pkgdesc="System Information Gatherer And Reporter"
url="https://github.com/hyperic/sigar/"
# aarch64, riscv64, loongarch64: missing openjdk8
arch="all !aarch64 !riscv64 !loongarch64"
license="Apache-2.0"
depends="$pkgname-native=$pkgver-r$pkgrel"
subpackages="$pkgname-native"
makedepends="apache-ant libtirpc-dev linux-headers openjdk8 perl"
source="https://github.com/hyperic/$_pkgname/archive/$_pkgname-$pkgver.tar.gz
	musl-compat-HZ.patch
	musl-compat-strerror_r.patch
	tirpc.patch
	java-sigar-include-sysmacros.patch
	fix-inlined-functions-definition.patch
	"
builddir="$srcdir/$_pkgname-$_pkgname-$pkgver"

build() {
	cd "$builddir"/bindings/java
	ant build
}

package() {
	cd "$builddir"/bindings/java

	install -m 644 -D sigar-bin/lib/sigar.jar \
		"$pkgdir"/usr/share/java/$_pkgname-$pkgver.jar
	ln -s $_pkgname-$pkgver.jar "$pkgdir"/usr/share/java/$_pkgname.jar
}

native() {
	pkgdesc="$pkgdesc (native library)"
	depends=""

	cd "$builddir"/bindings/java
	install -m 755 -D sigar-bin/lib/libsigar-*-linux.so \
		"$subpkgdir"/usr/lib/libsigar.so
}

sha512sums="0515f3501a51357d6ac01dc5e3ecffae10995f347b98c66928adff247b86e52112d2bf9cf78b2633941eb9c7fb23f019f4885c41348fe461239e4eebd147253e  sigar-1.6.4.tar.gz
bfb4f6f945207be652c58cfc8d3a552c84424d0ca9a3c0bf4177f4caa24c65a44ed3342b28d6d80d82a3e61d72f61d9c4194902bafa5372710db71f85e713f0f  musl-compat-HZ.patch
ea85154edc0ca2b15d556bbfe4fa61b37d2a53befa969b4c91d976b502f14ce138b0dbbd7d46985aa809a490df97b6ef388f3f16820e1e14b52fc85851342527  musl-compat-strerror_r.patch
c6bda65e389a62495951a908f675fbe4aa24b3b819e8e4bc9fee87e9e59ca5533b9ad738737d42f7d7665cc077a3bbc868420aa281536d0673a62e94b165488c  tirpc.patch
678fe505286ec31297d1459788f44144ecd7f35a35523f53be8cf8d699e45491a4573968ac8e8f88620acdae49e5aa2b130dc18c1c7c311b026b3ed1e65166fe  java-sigar-include-sysmacros.patch
ff313c86155c6c6e827cca1ea092308fce3f57eff88fb097e7f2f125ce42b44e45de57f7f45dd0b440fae854a169fad3e2ebe9d2fc9f2c7406413928ed081e15  fix-inlined-functions-definition.patch"
